<?php
  //Buffer larger content areas like the main page content
  ob_start();
require_once("auth.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="js/validationcus.js"></script>
<script>
var count=0;

function load(thediv, thefile) /* 2 parameters passed into here: the id of the div container and the name of the page to go to */
{  
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');  
    }
    xmlhttp.addEventListener("error", transferFailed, false);  
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById( thediv ).innerHTML = xmlhttp.responseText;
        }
    }  
 
   xmlhttp.open('GET', thefile, true);
    xmlhttp.send();
	    
}

function transferFailed(evt) {  
  alert("An error occurred while transferring the file.");  
}

</script>

</head>

<body>
<?php 
include("config.php");
if(isset($_REQUEST['id']))
{
$id=$_REQUEST['id'];
$data=mysql_query("select * from customers where serial='$id'");
$no=mysql_num_rows($data);
if($no!=0)
{
	while($rec=mysql_fetch_assoc($data))
	{

?>

<form action="updatecustomers.php" method="post"  enctype="multipart/form-data" id="frmCustomer">
<fieldset >
<legend style="color:#FD0002">Update Customers </legend>
			<div id="status"></div>

<table width="80%" align="center">
<tr>
<td width="23%">CustomerName</td>
<td width="27%"><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="text" name="txtCustomerName" id="txtCustomerName" value="<?php echo $rec['name']; ?>" /></td></tr>
<tr>
<td>Address:</td>
<td><textarea id="textAdd" name="textAdd"> <?php echo $rec['address']; ?></textarea></td></tr>
<tr><td width="24%">Email</td>
<td width="26%"><input type="text" name="txtEmail" id="txtEmail" value="<?php echo $rec['email']; ?>"/></td>
</tr><tr>
<td>Phone:</td><td><input type="text" name="txtPhone" id="txtPhone" value="<?php echo $rec['phone']; ?>" onkeypress="return numbersonly(event);"></td>
</tr>

<tr><td colspan="3"><input type="button" name="btnUpdateCustomer" value="Update Customer" onclick="validateForm2('updatecustomers.php','frmCustomer','thediv','<img src=\'pleasewait.gif\'>');"/></td></tr>
</table>
</fieldset>
  	</form>
	<?php
	}}}
	else
	{
	?>
	
	
<form action="addcustomers.php" method="post"  enctype="multipart/form-data" id="frmCustomer">
<fieldset >
<legend style="color:#FD0002">Add Customers </legend>
			<div id="status"></div>

<table width="80%" align="center">
<tr>
<td width="23%">CustomerName</td>
<td width="27%"><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="text" name="txtCustomerName" id="txtCustomerName" value="<?php echo $rec['name']; ?>" /></td></tr>
<tr>
<td>Address:</td>
<td><textarea id="textAdd" name="textAdd"> <?php echo $rec['Address']; ?></textarea></td></tr>
<tr><td width="24%">Email</td>
<td width="26%"><input type="text" name="txtEmail" id="txtEmail" value="<?php echo $rec['email']; ?>"/></td>
</tr><tr>
<td>Phone:</td><td><input type="text" name="txtPhone" id="txtPhone" value="<?php echo $rec['phone']; ?>"></td>
</tr>

<tr><td colspan="3"><input type="button" name="btnaddCustomer" value="Add Customer"  onclick="validateForm2('addcustomers.php','frmCustomer','thediv','<img src=\'pleasewait.gif\'>');"/></td></tr>
</table>
</fieldset>
  	</form>
	<?php
	}
	?>
</body>
</html>
 <?php
  //Assign all Page Specific variables
  $pagemaincontent = ob_get_contents();
  ob_end_clean();
  $pagetitle = "Customers";
  //Apply the template
  include("master.php");
?>    